<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class kategori_model extends CI_Model {
	var $table = "jonu_category";

	public function get_all(){
		$query = $this->db->get($this->table);
		$result = $query->result_array();
		return $result;
	}

	public function count_all(){
		$query = $this->db->count_all_results($this->table);
		return $query;
	}

	public function all_paged($num, $offset){
		$this->db->order_by('jonu_category_id', 'desc');		
		$query = $this->db->get($this->table, $num, $offset);
		$result = $query->result_array();
		return $result;
	}

	public function get_by_id($id){
		$this->db->where('jonu_category_id', $id);
		$query = $this->db->get($this->table);
		$result = $query->result_array();

		return $result;
	}

	public function store($param){
		$data = array(
			'jonu_category_name'	=> $param['cat_name'],
			'jonu_category_alias'	=> $param['cat_alias'],
			'jonu_category_hastag'	=> $param['cat_hastag'],
			'jonu_category_desc'	=> $param['cat_desc']
			);
		$query = $this->db->insert($this->table, $data);
		return $query;
	}

	public function update($param, $id){
		$data = array(
			'jonu_category_name'	=> $param['cat_name'],
			'jonu_category_alias'	=> $param['cat_alias'],
			'jonu_category_hastag'	=> $param['cat_hastag'],
			'jonu_category_desc'	=> $param['cat_desc']
			);
		$this->db->where('jonu_category_id', $id);
		$query = $this->db->update($this->table, $data);

		return $query;
	}

	public function destroy($id){
		$this->db->where('jonu_category_id', $id);
		$query = $this->db->delete($this->table);

		return $query;
	}
}

/* End of file kategori_model.php */
/* Location: ./application/models/kategori_model.php */